package im.demo.fileserv;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.io.IOException;
import java.util.Properties;

@WebListener
public class InitializeListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent event) {

        Properties fileProps = new Properties();

        try {

            fileProps.load(this.getClass().getClassLoader().getResourceAsStream("fileserver.properties"));

            event.getServletContext().setAttribute("fileProps", fileProps);

        } catch (IOException e) {

            e.printStackTrace();

        }

    }

    @Override
    public void contextDestroyed(ServletContextEvent event) {

    }
}
